from django.shortcuts import render,redirect
from django.contrib.auth import authenticate,login,logout
# Create your views here.

def logins(request):
    if request.method == 'POST':
        username=request.POST.get('username')
        pwd=request.POST.get('password')
        user=authenticate(username=username,password=pwd)
        if user:

            login(request,user)
            return render(request,'index.html')
        else:
            print('密码错误')
    return render(request,'login.html')

def logouts(request):
    logout(request)
    return redirect('/login')

def index(request):
    return render(request,'index.html')